import 'package:flutter/material.dart';
import 'package:flutter_webview/flutter_webview.dart';
import 'package:flutter_webview/flutter_webview_controller.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  late FlutterWebViewController controller;

  @override
  void initState() {
    super.initState();
    controller = FlutterWebViewController()
      ..addRouterHandler((path) => print(path))
      ..loadFlutterAsset('assets/www/index.html');
  }

  void _onMessageReceived(String data) {
    print(data);
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: FlutterWebView(controller),
      ),
    );
  }
}
